package com.ruoyi.finance.controller;

import com.ruoyi.finance.domain.User;
import com.ruoyi.finance.domain.UserDto;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: qs
 * @Date: 2025/3/6 21:01
 * @Description:
 **/
public class Test {
    public static void main(String[] args) {
        List<User> users= Arrays.asList(

                new User("小明", 55, "北京"),
                new User("小红", 32, "上海"),
                new User("小刚", 10, "北京"),
                new User("小花", 24, "北京")
        );

        List<User> collect = users.stream().filter(o -> o.getAge() < 30).collect(Collectors.toList());
        collect.forEach(System.out::println);
        List<UserDto> collect1 = collect.stream().map(o -> {
            UserDto userDto = new UserDto();
            userDto.setName(o.getName());
            userDto.setAge(o.getAge());
            return userDto;
        }).collect(Collectors.toList());
        collect1.forEach(System.out::println);

    }
}
